import * as actionTypes from '../../type/index.js'

const initialState = []

export default function userinfo (state = initialState, action) {
    switch (action.type) {
        case actionTypes.USER_UPDATE:
            return action.data
        case actionTypes.USER_ADD:
            state.push(action.data)
            return state
        case actionTypes.USER_DELECT:
            return state.filter(item => {
                if (item.id !== action.data.id) {
                    return item
                }
            })
        default:
            return state
    }
}